function plugin (Vue) {
  if (plugin.installed) {
    return
  }

  !Vue.prototype.$auth && Object.defineProperties(Vue.prototype, {
    $auth: {
      get () {
        const _this = this
        return (permissions) => {
          if (permissions === undefined || permissions === null || permissions === '') {
            return true
          }
          const permissionList = _this.$store.getters.permissions || []
          return permissionList.indexOf(permissions) > -1
        }
      }
    }
  })
}

export default plugin
